package com.crazymaker.springcloud.seckill.dao;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;


/**
 * Created by 尼恩 on 2019/7/18.
 */
@Repository
public interface SeckillSegmentStockMapper {

//    @Transactional
//    @Modifying
//    @Query("update SeckillSegmentStockPO  s set s.stockCount = s.stockCount-1  where s.skuId = :skuId and s.segmentIndex = :segmentIndex" )
    int decreaseStock(@Param("skuId") Long skuId, @Param("segmentIndex") Integer segmentIndex);


//    @Transactional
//    @Modifying
//    @Query("delete  from  SeckillSegmentStockPO s where s.skuId = :skuId" )
    int deleteStockBySku(@Param("skuId") Long skuId);

//    @Query("select sum(s.stockCount) from SeckillSegmentStockPO s where s.skuId = :skuId " )
    int sumStockCountById(@Param("skuId") Long skuId);


}
